package com.niiwoo.civet.trade.dto.request;

import com.niiwoo.civet.base.enums.RefundTypeEnum;
import com.niiwoo.civet.trade.enums.refund.RefundFundTypeEnum;
import com.niiwoo.tripod.provider.exception.NoSuchEnumValueException;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

@Setter
@Getter
@ToString
public class RefundWithholdRequestDTO implements Serializable
{
    @NotNull
    @Min(value = 1)
    private Long projectId;

    private String orgRequestNo;//机构请求流水号

    private String borrowUserId;

    List<Integer> periods;//指定还款的期数
    @NotNull
    private WithHoldOptTypeEnum optType;//还款操作类型

    @NotNull
    private RefundTypeEnum refundType;//1-立即还款，2-提前结清

    @NotNull
    private WithHoldTradeSourceEnum tradeSource;//交易来源

    private BigDecimal amount;//代扣充值金额

    private RefundFundTypeEnum refundFundTypeEnum = RefundFundTypeEnum.WITHHOLD_REFUND;//1代扣还款，2余额还款

    private Long payChannelId; //提定支付通道

    private String batchNo;// 批次号

    /**
     * 代扣订单处理状态
     */
    @AllArgsConstructor
    @Getter
    public enum WithholdOrderProcessingEnum
    {
        PROCESSING((byte)1,"处理中"),SUCCESS((byte)2,"成功"),FAILURE((byte)3,"失败");
        private Byte value;
        private String description;

        public static WithholdOrderProcessingEnum enumOf(Byte value) {
            for (WithholdOrderProcessingEnum withholdOrderProcessingEnum : WithholdOrderProcessingEnum.values())
            {
                if(withholdOrderProcessingEnum.getValue().equals(value))
                {
                    return withholdOrderProcessingEnum;
                }
            }
            throw new NoSuchEnumValueException("WithholdOrderProcessingEnum:" + value);
        }
    }

    @AllArgsConstructor
    @Getter
    public enum WithHoldTradeSourceEnum
    {
        SHENDUN((byte)1,"神盾触发"), JOB((byte)2,"job触发"),
        R360((byte)3,"r360触发"),CARNIU((byte)4,"卡牛触发"),
        HUIJIE((byte)5,"汇借触发"),SWEET((byte)6,"你我他宙斯盾触发"),
        OVERDUE_50_DAY((byte)7,"逾期50天")
        ;
        private Byte value;
        private String description;
        public static WithHoldTradeSourceEnum enumOf(Byte value) {
            for (WithHoldTradeSourceEnum withHoldTradeSourceEnum : WithHoldTradeSourceEnum.values())
            {
                if(withHoldTradeSourceEnum.getValue().equals(value))
                {
                    return withHoldTradeSourceEnum;
                }
            }
            throw new NoSuchEnumValueException("WithHoldTradeSourceEnum:" + value);
        }
    }

    @AllArgsConstructor
    @Getter
    public enum WithHoldOptTypeEnum
    {
        NORMAL((byte)1,"正常还款"), PERIODS((byte)2,"按期还款");
        private Byte value;
        private String description;
        public static WithHoldOptTypeEnum enumOf(Byte value) {
            for (WithHoldOptTypeEnum optTypeEnum : WithHoldOptTypeEnum.values())
            {
                if(optTypeEnum.getValue().equals(value))
                {
                    return optTypeEnum;
                }
            }
            throw new NoSuchEnumValueException("WithHoldOptTypeEnum:" + value);
        }
    }

}
